/*
 * @Author: asushiye
 * @Date: 2020-07-03 08:51:09
 * @Commit: file content
 */
import { Injectable } from '@angular/core';
import { AfMessageService, gw_code_g } from '@core';
import { _HttpClient } from '@delon/theme';
import { Observable } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class CgDataSourceService {
  constructor(
    private http: _HttpClient,
    private msg: AfMessageService
  ) {}

  public get httpClient(): _HttpClient {
    return this.http;
  }

  public query(dbSourceName: string): Observable<any> {
    return this.http.get(`${gw_code_g}/db/datasource/query?sourceName=${dbSourceName}`);
  }

  public save(body: any): Observable<any> {
    return this.http.post(`${gw_code_g}/db/datasource/save`, body);
  }

  public delete(id: any): Observable<any> {
    return this.http.get(`${gw_code_g}/db/datasource/delete/${id}`);
  }

  public testLink(id: any): Observable<any> {
    return this.http.get(`${gw_code_g}/db/datasource/test/link/${id}`);
  }

  public testLinkClick(body: any): Observable<any> {
    return this.http.post(`${gw_code_g}/db/datasource/test/link`, body);
  }
}
